package xmlMapping.lts;

import java.io.Serializable;

/**
 * 该类为共享股票池中，多账号对买、卖数量的记录
 * Created by David on 2018/1/11.
 */
public class SharedInstrumentPoolHeld implements Serializable {
    private String instrumentPoolId;
    private String symbol;
    private String account;
    private String route;
    private double buyHeld;
    private double sellHeld;
    private double position;

    public SharedInstrumentPoolHeld() {
    }

    public SharedInstrumentPoolHeld(String instrumentPoolId, String symbol, String account, String route) {
        this.instrumentPoolId = instrumentPoolId;
        this.symbol = symbol;
        this.account = account;
        this.route = route;
        this.buyHeld = 0d;
        this.sellHeld = 0d;
        this.position = 0d;
    }

    public String getInstrumentPoolId() {
        return instrumentPoolId;
    }

    public void setInstrumentPoolId(String instrumentPoolId) {
        this.instrumentPoolId = instrumentPoolId;
    }

    public String getSymbol() {
        return symbol;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public double getBuyHeld() {
        return buyHeld;
    }

    public void setBuyHeld(double buyHeld) {
        this.buyHeld = buyHeld;
    }

    public double getSellHeld() {
        return sellHeld;
    }

    public void setSellHeld(double sellHeld) {
        this.sellHeld = sellHeld;
    }

    public double getPosition() {
        return position;
    }

    public void setPosition(double position) {
        this.position = position;
    }

    public void addBuyHeld(double held) {
        this.buyHeld += held;
        this.position += held;
    }

    public void addSellHeld(double held) {
        this.sellHeld += held;
        this.position -= held;
    }

    public String getRoute() {
        return route;
    }

    public void setRoute(String route) {
        this.route = route;
    }

    double getMaxHeld() {
        return Math.max(this.buyHeld, this.sellHeld);
    }

    @Override
    public String toString() {
        return "SharedInstrumentPoolHeld{" +
                "instrumentPoolId='" + instrumentPoolId + '\'' +
                ", symbol='" + symbol + '\'' +
                ", account='" + account + '\'' +
                ", route='" + route + '\'' +
                ", buyHeld=" + buyHeld +
                ", sellHeld=" + sellHeld +
                ", position=" + position +
                '}';
    }
}
